<template>
  <div>
    <el-form v-model="ruleForm" :rules="rules">
      <el-form-item label="团长姓名" prop="captain">
        <el-input
            v-if="!captainDesenShow"
            v-model="ruleForm.captain"
            placeholder="团长姓名"
            :maxlength="100"
            @focus="captainDesenShow = false"
            @blur="captainBlur(ruleForm.captain)"
        ></el-input>
        <el-input
            v-else
            v-model="captainDesen"
            placeholder="团长姓名"
            @focus="captainDesenShow = false"
            @blur="captainDesenShow = true"
        ></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    let checkName = (rule, value, callback) => {

      if (!this.ruleForm.captain) {
        callback(new Error('请输入姓名'));
      }  else {
        callback();
      }
    };
    return {
      ruleForm: {
        captain: ''
      },
      captainDesenShow: true,
      captainDesen: "",
      rules:{
        captain: [
            { validator:checkName,trigger:'blur' },
        ]
      }
    }
  },
  methods: {
    captainBlur(captain) {
      //*脱敏
      this.captainDesen = captain ? this.regular.tmName(captain) : "";//脱敏
      this.captainDesenShow = true;
    },
  }
}
</script>

<style scoped>

</style>